<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>key关键字在Vue中的作用</title>
  <style>
    #app ul {
      width: 80px;
      list-style: none;
    }

    .red {
      color: red;
    }

    .click {
      padding-top: 15px;
      cursor: pointer;
      transition: 0.3s;
    }

    .click:hover {
      transform: scale(1.2, 1.2);
    }
  </style>
</head>

<body>

  <div id="app">
    <ul>
      <!-- key绑定item元素 与 item一一对应，结构节点唯一，列表再进行中间插入会直接生成一个新的li标签，提高性能 -->
      <li class="click" v-for="(item, index) in letters" :key="index">{{ item }}</li>
    </ul>
  </div>

  <script src="../../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        letters: ['a', 'b', 'c', 'd', 'e']
      }
    })
  </script>
</body>

</html>